package cn.kai.system.listener;

import cn.kai.system.service.IPermissionScanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * @Author Kai
 * @Date 2022/6/22 10:58
 * @PackageName:cn.kai.basic.listener
 * @ClassName: PermissionScanInitListener
 * @Description: 权限扫描监听类
 * @Version 1.0
 */
//申明自定义的web监听器，被容器注册和使用
@WebListener
@Slf4j
public class PermissionScanInitListener implements ServletContextListener {
    @Autowired
    private IPermissionScanService permissionScanService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                log.info("权限初始化开始******************************************");
                permissionScanService.scanPermission();
                log.info("权限初始化结束****************** ************************");
            }
        }).start();
    }
}
